#include "KeyPad.h"
#include "../SGD Wrappers/SGD_Event.h"
#include "Player.h"
KeyPad::KeyPad() : Listener(this)
{

}


KeyPad::~KeyPad()
{
}
void KeyPad::HandleEvent(const SGD::Event* pEvent)
{
	if (pEvent->GetEventID() == "END_INTERACTION")
	{
		SGD::Event* msg = new SGD::Event("OPEN");
		msg->QueueEvent((BaseObject*)door);
		msg = nullptr;
	}
	if (pEvent->GetEventID() == triggerEvent.c_str())
	{
		Player* player = (Player*)pEvent->GetData();
		if (player->HasKey() == true)
		{
		SGD::Event* msg = new SGD::Event(doorEvent.c_str());
			msg->QueueEvent((BaseObject*)door);
			msg = nullptr;
		}
		
	}
}
void KeyPad::HandleCollision(const IBase* pOther)
{
	if (pOther->GetType() == OBJ_PLAYER)
	{
		SGD::Event* msg = new SGD::Event("INTERACT_WITH", (void*)nullptr, (BaseObject*)this);

		msg->QueueEvent();
		msg = nullptr;

	}

}
SGD::Rectangle KeyPad::GetRect(void)	const
{
	return SGD::Rectangle(m_ptPosition - m_szSize, m_szSize * 1.5f);

}
void KeyPad::SetDoor(BaseObject* pDoor)
{
	if (door != nullptr)
	{
		door->Release();
		door = nullptr;
	}
	door = pDoor;
}
